home *** CD-ROM | disk | FTP | other *** search
/ Amoszine 4 / Amoszine 4 (Disk 1 of 3).adf / ARTS / Arrays.asc < prev    next >
Encoding:
Text File  |  1992-02-26  |  1.5 KB  |  44 lines

  1. @2
  2.                                 ARRAYS IN AMOS
  3.                                 ==============
  4. @1
  5. You probably all know how to use arrays in AMOS. If not you`re missing
  6. out on a treat that is needed to fully appreciate the programming
  7. language.
  8.  
  9. An array is a storage area in the computer`s memory. Just like a
  10. variable it is given a name, but it is also given a size. Because of
  11. this it is important to set it up before it can be used.
  12.  
  13. To do this use the command:
  14. @2
  15. Dim ARRAY(N) -where ARRAY is the name of the array
  16.                     N is the size of the array.
  17. @1
  18. The array name follows the standard format of variables in AMOS, eg
  19. NUMBERS for numeric data or LETTER$ for words. The command creates a
  20. series of boxes numbered from 0 to N that can each be written to in
  21. the same way as any other variable (provided the number part or element
  22. of the array is specified).
  23.  
  24. Each element will initially be blank, that`s the equivalent of 0 in a
  25. numerical array or "" in any other.
  26.  
  27. For example try this program to create an array in AMOS and fill it
  28. from random numbers.
  29.  
  30. @2
  31. Dim NUMBERS(10)
  32. For COUNTER=0 To 10
  33.   NUMBERS(COUNTER)=Rnd(9)+1
  34. Next COUNTER
  35. @1
  36.  
  37. This is the equivalent of creating 11 variables and filling them with a
  38. number from 1 to 10. As I`m sure you`ll appreciate this is a much more
  39. efficient method and has the advantage that it is much easier to call
  40. up a particular value. Arrays have major uses in any of today`s games
  41. or application programs.
  42. @3
  43. Thomas Lancaster
  44.